#!/usr/bin/python

import time, sys
from math import pow as power

""" 
The sum of the squares of the first ten natural numbers is,

1^2 + 2^2 + ... + 10^2 = 385
The square of the sum of the first ten natural numbers is,

(1 + 2 + ... + 10)^2 = 552 = 3025
Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025  385 = 2640.

Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum.
"""

def sumofsq(n):
    return sum([ x * x for x in range(1, n + 1) ])
    
def sqofsum(n):
    return power(sum([ x for x in range(1, n + 1) ]), 2)

    
    
def main():
    start = time.time()
    
    n = 10
    a, b = sumofsq(n), sqofsum(n)
    print '{0}, {1}, diff: {2}'.format(a, b, abs(a - b) )

    n = 100
    a, b = sumofsq(n), sqofsum(n)
    print '{0}, {1}, diff: {2}'.format(a, b, abs(a - b) )
    
    print '{0:.2f} s'.format(time.time() - start)        

# solution 1: 338350, 25502500 diff: 25164150

if __name__ == '__main__':
  main()
